import 'dart:io';

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:photo_frame/utils/util_func.dart';

class MeAvatarCell extends StatelessWidget {
  final String? avatar;
  final String? name;
  final String? email;
  final int? avatarColor;
  final GestureTapCallback? pickAvatar;
  final GestureTapCallback? editNickname;

  MeAvatarCell(
      {this.avatar,
      this.avatarColor,
      this.name,
      this.email,
      this.pickAvatar,
      this.editNickname,
      super.key});

  @override
  Widget build(BuildContext context) {
    return Container(
      height: 102,
      margin: EdgeInsets.only(top: 12),
      padding: EdgeInsets.only(left: 20, right: 20),
      decoration: BoxDecoration(
        borderRadius: BorderRadius.circular(10),
        color: Colors.white,
      ),
      child: Row(children: [
        Stack(
          children: [
            SizedBox(
              width: 76,
              height: 102,
              child: Stack(
                children: [
                  Positioned(
                    top: 16,
                    child: ClipRRect(
                      borderRadius: BorderRadius.circular(35),
                      child: Container(
                        child: avatar == null
                            ? Image.asset("images/pic_default_avatar.png",
                                width: 70, height: 70)
                            : Image.network(
                                avatar ?? "",
                                width: 70,
                                height: 70,
                                fit: BoxFit.cover,
                              ),
                      ),
                    ),
                  )
                ],
              ),
            ),
            Positioned(
                right: -5,
                bottom: 5,
                child: CupertinoButton(
                  padding: EdgeInsets.zero,
                  onPressed: pickAvatar,
                  child: Image.asset(
                    "images/icon_camera.png",
                    width: 28,
                    height: 28,
                  ),
                ))
          ],
        ),
        SizedBox(width: 10),
        Expanded(child: Text(name ?? email ?? "")),
        SizedBox(
          width: 20,
        ),
        CupertinoButton(
          padding: EdgeInsets.zero,
          onPressed: editNickname,
          child: Container(
            color: Colors.white,
            width: 30,
            height: 90,
            child: Row(
              children: [
                Expanded(child: SizedBox()),
                Image.asset(
                  "images/icon_pen.png",
                  width: 14,
                  height: 14,
                )
              ],
            ),
          ),
        )
      ]),
    );
  }
}
